﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EnvironmentalMonitor.Support.Business.Environmental;
using EnvironmentalMonitor.Support.Business;
using EnvironmentalMonitor.Support.Module;
using EnvironmentalMonitor.Support.Resource;

namespace EnvironmentalMonitor.WebApplication.Environmental.Detector
{
    public partial class ViewJson : EnvironmentalMonitor.WebApplication.Abstract.AbstractListJson
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            const string MACHINE_ID = "machineId";

            string machineId = this.ParameterString(MACHINE_ID);

            DetectorBusiness business = new DetectorBusiness();
            List<EnvironmentalMonitor.Support.Module.Environmental.Detector> modules = business.QueryValidityByMachine(machineId);

            this.ListJsonData = new Abstract.ListJsonData();
            this.ListJsonData.total = modules.Count;
            this.ListJsonData.rows = modules;
            string json = this.Json();

            this.Response.Write(json);
            this.Response.Flush();
            this.Response.End();
        }
    }
}